﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using Public;
namespace DAL
{
    public class ChuyenBayDAL
    {
        clsKetNoi kn = new clsKetNoi();
        public DataTable LoadChuyenBay()
        {
            
            return kn.LayDuLieu("ChuyenBay_Load");
        }
        public DataTable LoadChuyenBay_Ve()
        {

            return kn.LayDuLieu("ChuyenBay_Ve");
        }
        public int ThemChuyenBay(ChuyenBayPublic p)
        {
            int Nparameter = 9;
            string[] name = new string[Nparameter];
            object[] value= new object[Nparameter];
            name[0] = "@MaChuyenBay"; value[0] = p.MaChuyenBay;
            name[1] = "@MaTuyenBay"; value[1] = p.MaTuyenBay;
            name[2] = "@SanBayDi"; value[2] = p.SanBayDi;
            name[3] = "@SanBayDen"; value[3] = p.SanBayDen;
            name[4] = "@NgayGio"; value[4] = p.NgayGio;
            name[5] = "@ThoiGianBay"; value[5] = p.ThoiGianBay;
            name[6] = "@SoLuongGheHang1"; value[6] = p.SoLuongGheHang1;
            name[7] = "@SoLuongGheHang2"; value[7] = p.SoLuongGheHang2;
            name[8] = "@GiaTien"; value[8] = p.GiaTien;
            return kn.Update("ChuyenBay_Insert",name,value,Nparameter);

        }
        public int SuaChuyenBay(ChuyenBayPublic p)
        {
            int Nparameter = 9;
            string[] name = new string[Nparameter];
            object[] value = new object[Nparameter];
            name[0] = "@MaChuyenBay"; value[0] = p.MaChuyenBay;
            name[1] = "@MaTuyenBay"; value[1] = p.MaTuyenBay;
            name[2] = "@SanBayDi"; value[2] = p.SanBayDi;
            name[3] = "@SanBayDen"; value[3] = p.SanBayDen;
            name[4] = "@NgayGio"; value[4] = p.NgayGio;
            name[5] = "@ThoiGianBay"; value[5] = p.ThoiGianBay;
            name[6] = "@SoLuongGheHang1"; value[6] = p.SoLuongGheHang1;
            name[7] = "@SoLuongGheHang2"; value[7] = p.SoLuongGheHang2;
            name[8] = "@GiaTien"; value[8] = p.GiaTien;
            return kn.Update("ChuyenBay_Edit", name, value, Nparameter);
        }
        public int XoaChuyenBay(ChuyenBayPublic p)
        {
            int Nparameter = 1;
            string[] name = new string[Nparameter];
            object[] value = new object[Nparameter];
            name[0] = "@MaChuyenBay"; value[0] = p.MaChuyenBay;
            return kn.Update("ChuyenBay_Delete", name, value, Nparameter);

        }
        public DataTable ChuyenBay_Search(ChuyenBayPublic p)
        {
            int Nparameter = 2;
            string[] name = new string[Nparameter];
            object[] value = new object[Nparameter];
            name[0] = "@SanBayDi"; value[0] = p.SanBayDi;
            name[1] = "@SanBayDen"; value[1] = p.SanBayDen;
            return kn.LayDuLieu("ChuyenBay_Search",name,value,Nparameter);
        }
    }
}
